package com.jindy.module.clearingMarginDetailView.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.clearingMarginDetailView.domain.ClearingMarginDetailView;
import com.jindy.module.clearingMarginDetailView.service.IClearingMarginDetailViewService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * 结算毛利明细
 * 
 * @author jindy
 * @date 2023-06-06
 */
@RestController
@RequestMapping("/module/clearingMarginDetailView")
public class ClearingMarginDetailViewController extends BaseController
{
    @Autowired
    private IClearingMarginDetailViewService clearingMarginDetailViewService;

    /**
     * 查询结算毛利明细
     */
    @PreAuthorize("@ss.hasPermi('module:clearingMarginDetailView:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClearingMarginDetailView clearingMarginDetailView)
    {
        startPage();
        List<ClearingMarginDetailView> list = clearingMarginDetailViewService.selectClearingMarginDetailViewList(clearingMarginDetailView);
        return getDataTable(list);
    }

    /**
     * 导出结算毛利明细
     */
    @PreAuthorize("@ss.hasPermi('module:clearingMarginDetailView:export')")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ClearingMarginDetailView clearingMarginDetailView)
    {
        List<ClearingMarginDetailView> list = clearingMarginDetailViewService.selectClearingMarginDetailViewList(clearingMarginDetailView);
        ExcelUtil<ClearingMarginDetailView> util = new ExcelUtil<ClearingMarginDetailView>(ClearingMarginDetailView.class);
        util.exportExcel(response, list, "结算毛利明细");
    }

    /**
     * 获取结算毛利明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:clearingMarginDetailView:query')")
    @GetMapping(value = "/{salesmanName}")
    public AjaxResult getInfo(@PathVariable("salesmanName") String salesmanName)
    {
        return AjaxResult.success(clearingMarginDetailViewService.selectClearingMarginDetailViewBySalesmanName(salesmanName));
    }

    /**
     * 新增结算毛利明细
     */
    @PreAuthorize("@ss.hasPermi('module:clearingMarginDetailView:add')")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClearingMarginDetailView clearingMarginDetailView)
    {
        return toAjax(clearingMarginDetailViewService.insertClearingMarginDetailView(clearingMarginDetailView));
    }

    /**
     * 修改结算毛利明细
     */
    @PreAuthorize("@ss.hasPermi('module:clearingMarginDetailView:edit')")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClearingMarginDetailView clearingMarginDetailView)
    {
        return toAjax(clearingMarginDetailViewService.updateClearingMarginDetailView(clearingMarginDetailView));
    }

    /**
     * 删除结算毛利明细
     */
    @PreAuthorize("@ss.hasPermi('module:clearingMarginDetailView:remove')")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
	@DeleteMapping("/{salesmanNames}")
    public AjaxResult remove(@PathVariable String[] salesmanNames)
    {
        return toAjax(clearingMarginDetailViewService.deleteClearingMarginDetailViewBySalesmanNames(salesmanNames));
    }
}
